angular.module('starter.controllers')
  .controller('itemPerformanceCtr', function ($scope, preData, $stateParams, $state, $q) {
    console.info("ctr");
    console.info(preData);
    console.info($stateParams);
    $scope.$on('$ionicView.loaded', () => {
      $scope.data = {};
      $scope.time = {};
      $scope.time.starTime = new Date();
      angular.copy(preData, $scope.data);
      $scope.data.nums = $stateParams.nums;
    });

    $scope.$on('$ionicView.beforeEnter', () => {
      $scope.time.endTime = new Date();
      $scope.time.difference = $scope.time.endTime.getTime() - $scope.time.starTime.getTime();
      console.info($scope.time);
    });

    $scope.back = () => {
      var obj = {};
      obj.difference = $scope.time.difference;
      obj.title = $scope.data.nums;
      obj.d1 = {};
      obj.d1 = $scope.time.difference;
      window.localStorage.setItem('key', angular.toJson(obj));
      $state.go('listPerformance');
    }
  });
